﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using BaseballGame.Models;

namespace BaseballGame.Controllers
{
    public class addPositionController : Controller
    {
        private game_entitiesDbContext db = new game_entitiesDbContext();

        //
        // GET: /addPosition/

        public ActionResult Index()
        {
            return View(db.positions.ToList());
        }

        //
        // GET: /addPosition/Details/5

        public ActionResult Details(int id = 0)
        {
            positions positions = db.positions.Find(id);
            if (positions == null)
            {
                return HttpNotFound();
            }
            return View(positions);
        }

        //
        // GET: /addPosition/Create

        public ActionResult Create()
        {
            return View();
        }

        //
        // POST: /addPosition/Create

        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Create(positions positions)
        {
            if (ModelState.IsValid)
            {
                db.positions.Add(positions);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(positions);
        }


		public ActionResult RunGame()
		{
			return View();
		}

		[HttpPost]
		public ActionResult RunGame(int id = 0)
		{
			RunClass run = new RunClass();
			return RedirectToAction("Index", "Home");
		}

        //
        // GET: /addPosition/Edit/5

        public ActionResult Edit(int id = 0)
        {
            positions positions = db.positions.Find(id);
            if (positions == null)
            {
                return HttpNotFound();
            }
            return View(positions);
        }

        //
        // POST: /addPosition/Edit/5

        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Edit(positions positions)
        {
            if (ModelState.IsValid)
            {
                db.Entry(positions).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            return View(positions);
        }

        //
        // GET: /addPosition/Delete/5

        public ActionResult Delete(int id = 0)
        {
            positions positions = db.positions.Find(id);
            if (positions == null)
            {
                return HttpNotFound();
            }
            return View(positions);
        }

        //
        // POST: /addPosition/Delete/5

        [HttpPost, ActionName("Delete")]
        [ValidateAntiForgeryToken]
        public ActionResult DeleteConfirmed(int id)
        {
            positions positions = db.positions.Find(id);
            db.positions.Remove(positions);
            db.SaveChanges();
            return RedirectToAction("Index");
        }

        protected override void Dispose(bool disposing)
        {
            db.Dispose();
            base.Dispose(disposing);
        }
    }
}